﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Rsa
{
    /// <summary>
    /// Interaction logic for JanelaEmail.xaml
    /// </summary>
    public partial class JanelaEmail : UserControl
    {
        private GestorConfigXML Gxml = null;
        private List<Lista> ListaEmail = new List<Lista>();
        private LancarThreads _lancar = null;

        public JanelaEmail(GestorConfigXML gx)
        {
            InitializeComponent();
            Gxml = gx;
        }

        public void atualizarEmail(List<Lista> myLista)
        {
            
        }

        public LancarThreads Lancar
        {
            get { return _lancar; }
            set
            {
                _lancar = value;
                Lancar.emailEvento += new LancarThreads.EmailHandler(atualizarEmail);
            }
        }

        private void ReceberEmailButton_Click(object sender, RoutedEventArgs e)
        {
            
            
        }

        private void enviarEmailButton_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(toTextBox.Text))
                MessageBox.Show("Falta o campo Para");
            else
            {
                if (String.IsNullOrEmpty(assuntoTextBox.Text))
                    MessageBox.Show("Falta o campo Assunto");
                else
                {
                    if (String.IsNullOrEmpty(corpoTextBox.Text))
                        MessageBox.Show("Falta o campo Mensagem");
                    else
                    {
                        Lancar.sendEmail(toTextBox.Text, assuntoTextBox.Text, corpoTextBox.Text);
                        MessageBox.Show("Mensagem enviada com sucesso");
                        toTextBox.Text = "";
                        assuntoTextBox.Text = "";
                        corpoTextBox.Text = "";
                    }
                }
            }
        }

       
    }
}
